﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Drawing;
using System.Drawing.Imaging;

namespace LowLevelGraphics.SeamCarving
{
    /// <summary>
    /// Energy bias
    /// </summary>
    public class EnergyBias
    {
        // Energy bias map (to influence carving)
        public int[,] EnergyBiasMap { get; private set; }
        public EnergyBias(Size size)
        {
            // Initialize bias array
            EnergyBiasMap = new int[size.Width, size.Height];
        }

        /// <summary>
        /// Indexe for energy bias
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public int this[int x, int y, Size size]
        {
            get
            {
                if (EnergyBiasMap != null)
                {
                    if (x >= 0 && x < size.Width && y >= 0 && y < size.Height)
                    {
                        return EnergyBiasMap[x, y];
                    }
                    else
                    {
                        // Pixel is out of bounds
                        return 0;
                    }
                }
                else
                {
                    // No bias map set
                    return 0;
                }
            }
        }
    }
}
